package com.jiuye.common;

/**
 * ThreadLocal封装
 *
 * @author likeWen
 * @since 2022/11/2 10:49
 */
public class BaseContext {
    //把用户id保存到ThreadLocal中
    //用户ID是Long类型
    private static final ThreadLocal<Long> THREAD_LOCAL_CURRENT_USER_ID =new ThreadLocal<>();
    /**
     * 设置用户id
     */
    public static void setCurrentUserId(Long currentUserId){
        //设置值
        THREAD_LOCAL_CURRENT_USER_ID.set(currentUserId);
    }
    /**
     * 获取用户id
     */
    public static Long getCurrentUserId(){
        return THREAD_LOCAL_CURRENT_USER_ID.get();
    }
}
